//
//  BuzzVisibilityElements.m
//  Buzz API Demo
//
//  Created by Peter Hopkins on 5/10/10.
//  Copyright 2010 Google Inc. All rights reserved.
//
//  Licensed under the Apache License, Version 2.0 (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.
//

#import "BuzzVisibilityElements.h"

#import "BuzzConstants.h"
#import "PocoElements.h"

#import "GDataBaseElements.h"

#define kTypeAttr @"type"

@implementation BuzzVisibility

+ (NSString *)extensionElementURI { return kBuzzNamespace; }
+ (NSString *)extensionElementPrefix { return kBuzzNamespacePrefix; }
+ (NSString *)extensionElementLocalName { return @"visibility"; }


- (void)addExtensionDeclarations {
  [super addExtensionDeclarations];
  
  [self addExtensionDeclarationForParentClass:[self class]
                                   childClass:[BuzzAclEntry class]];
}


- (NSArray *)aclEntries {
  return [self objectsForExtensionClass:[BuzzAclEntry class]];
}


@end


@interface BuzzAclEntryURI : GDataValueElementConstruct <GDataExtension>
@end

@implementation BuzzAclEntryURI
+ (NSString *)extensionElementURI       { return kGDataNamespaceAtom; }
+ (NSString *)extensionElementPrefix    { return kGDataNamespaceAtomPrefix; }
+ (NSString *)extensionElementLocalName { return @"uri"; }
@end


@implementation BuzzAclEntry

+ (NSString *)extensionElementURI { return kBuzzNamespace; }
+ (NSString *)extensionElementPrefix { return kBuzzNamespacePrefix; }
+ (NSString *)extensionElementLocalName { return @"aclentry"; }

- (void)addParseDeclarations {
  [self addLocalAttributeDeclarations:[NSArray arrayWithObject:kTypeAttr]];
}

- (void)addExtensionDeclarations {
  [super addExtensionDeclarations];

  [self addExtensionDeclarationForParentClass:[self class]
   childClasses:[PocoID class],
   [BuzzAclEntryURI class],
   [PocoName class],
   nil];
}

- (NSString *)type {
  return [self stringValueForAttribute:kTypeAttr];
}

- (NSString *)pocoIdentifier {
  PocoID *obj = [self objectForExtensionClass:[PocoID class]];
  return [obj stringValue];
}

- (NSString *)URI {
  BuzzAclEntryURI *obj = [self objectForExtensionClass:[BuzzAclEntryURI class]];
  return [obj stringValue];
}

- (NSString *)pocoName {
  PocoName *obj = [self objectForExtensionClass:[PocoName class]];
  return [obj stringValue];
}

@end

